package com.example.xunai.dto.response.system;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class HealthCheckResponse {
    private String status;
    private String service;
    private Long timestamp;
    private Map<String, Object> details;

    public static HealthCheckResponse up(String service) {
        return HealthCheckResponse.builder()
                .status("UP")
                .service(service)
                .timestamp(System.currentTimeMillis())
                .build();
    }

    public static HealthCheckResponse up(String service, Map<String, Object> details) {
        return HealthCheckResponse.builder()
                .status("UP")
                .service(service)
                .timestamp(System.currentTimeMillis())
                .details(details)
                .build();
    }

    public static HealthCheckResponse down(String service, String error) {
        return HealthCheckResponse.builder()
                .status("DOWN")
                .service(service)
                .timestamp(System.currentTimeMillis())
                .details(Map.of("error", error))
                .build();
    }
}